package 设计模式;

public class EagerSingleton {
    
    private String no;

    // 某个类只能有一个实例
    private static EagerSingleton instance = new EagerSingleton();

    // 必须自行创建实例
    private EagerSingleton(){}
    
    // 必须自行向整个系统提供实例
    public static EagerSingleton getInstance(){
        instance.setNo("xxxxxxxxxxxxxxxxxxxx");
        return instance;
    }
    public String getNo(){
        return no;
    }
    public void setNo(String no){
        this.no = no;
    }
    public static void main(String[] args) {
        EagerSingleton s1 = EagerSingleton.getInstance();
        System.out.println(s1.no);
    }
}
